package _01世纪末的星期;

import java.util.Scanner;

public class _01_世纪末的星期1 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int year = 1999;
        int week = 4;//为了方便求模，0代表星期一，1999年12月31是星期五，初始化4
//		int[] data1 = new int[] {-1,31,28,31,30,31,30,31,31,30,31,30,31};
//		int[] data2 = new int[] {-1,31,29,31,30,31,30,31,31,30,31,30,31};//闰年天数

        for(year=2000;year<=9999;year++) {
            if((year%100!=0 && year%4==0) || year%400==0)
                week = (week+366)%7;
            else
                week = (week+365)%7;
            if(year%100==99)
                System.out.println(year+" "+week);
        }

    }

}